package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportUserCertificate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-12-04 11:33:03
 */
@Repository
public class TransportUserCertificateDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportUserCertificateDao.class);

    public TransportUserCertificate insert(final TransportUserCertificate transportUserCertificate) {
        insert("TransportUserCertificate.insert", transportUserCertificate);
        return transportUserCertificate;
    }

    public Boolean updateInfoById(final TransportUserCertificate transportUserCertificate) {
        return update("TransportUserCertificate.updateInfoById", transportUserCertificate) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportUserCertificate.updateInfoByQuery", query) > 0;
    }

    public TransportUserCertificate selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportUserCertificate.selectById", query);
    }

    public List<TransportUserCertificate> selectByQuery(final Query query) {
        return queryForList("TransportUserCertificate.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportUserCertificate.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportUserCertificate transportUserCertificate = new TransportUserCertificate();
        transportUserCertificate.setDeleteFlag(1);
        transportUserCertificate.setId(id);
        transportUserCertificate.setEntId(entId);

        return update("TransportUserCertificate.updateInfoById", transportUserCertificate) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportUserCertificate.deleteById", query) > 0;
    }
}